package com.piece.core.authentication.handler;

import com.piece.core.framework.support.response.AjaxResponse;
import com.piece.core.framework.util.string.JsonUtil;
import com.piece.core.web.util.ServletUtil;
import org.springframework.security.access.AccessDeniedException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 自定义认证用户无权限异常
 */
public class AccessDeniedHandler implements org.springframework.security.web.access.AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) {
        ServletUtil.renderString(response, JsonUtil.toJson(AjaxResponse.error(e.getMessage())));
    }
}
